package edu.uwm.cs552;

/**
 * Default track rental costs.
 * Normally 0.5, but increasing to 1.0 to cross an inlet.
 */
public class DefaultTrackRental implements TrackRental {
	private static TrackRental instance;
	
	public static TrackRental getInstance() {
		if (instance == null) instance = new DefaultTrackRental();
		return instance;
	}
	
	private DefaultTrackRental() {}

	public double cost(Terrain t1, Barrier b, Terrain t2) {
		// between suburbs of (presumably) the same city,
		// and going into the city center or out, is free
		if (t1 == Terrain.SUBURB && t2 == Terrain.SUBURB) return 0.0;
		if (t1 == Terrain.LARGE || t2 == Terrain.LARGE) return 0.0;
		if (b == null) return 0.5;
		switch (b) {
		default: return 0.5;
		case INLET: return 1.0; // charge extra for major bridges
		}
	}

}
